package com.ssy.lingxi.order.model.dto;

import com.ssy.lingxi.order.utils.NumberUtil;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.util.Objects;

/**
 * 合并下单，拆单的供应商、上级供应商中间数据
 * @author 万宁
 * @version 2.0.0
 * @date 2021-09-09
 */
public class OrderSeparateDTO implements Serializable {
    private static final long serialVersionUID = 7475337746325457565L;

    public OrderSeparateDTO(Long vendorMemberId, Long vendorRoleId, String vendorMemberName, Long supplyMemberId, Long supplyRoleId, String supplyMemberName) {
        this.vendorMemberId = vendorMemberId;
        this.vendorRoleId = vendorRoleId;
        this.vendorMemberName = vendorMemberName;
        this.supplyMemberId = NumberUtil.isNullOrNegative(supplyMemberId) ? 0L : supplyMemberId;
        this.supplyRoleId = NumberUtil.isNullOrNegative(supplyRoleId) ? 0L : supplyRoleId;
        this.supplyMemberName = StringUtils.hasLength(supplyMemberName) ? supplyMemberName : "";
    }

    /**
     * 供应商会员Id
     */
    private Long vendorMemberId;

    /**
     * 供应商会员角色Id
     */
    private Long vendorRoleId;

    /**
     * 供应商会员名称
     */
    private String vendorMemberName;

    /**
     * 上级供应商会员Id
     */
    private Long supplyMemberId;

    /**
     * 上级供应商会员角色Id
     */
    private Long supplyRoleId;

    /**
     * 上级供应商会员名称
     */
    private String supplyMemberName;

    public Long getVendorMemberId() {
        return vendorMemberId;
    }

    public void setVendorMemberId(Long vendorMemberId) {
        this.vendorMemberId = vendorMemberId;
    }

    public Long getVendorRoleId() {
        return vendorRoleId;
    }

    public void setVendorRoleId(Long vendorRoleId) {
        this.vendorRoleId = vendorRoleId;
    }

    public String getVendorMemberName() {
        return vendorMemberName;
    }

    public void setVendorMemberName(String vendorMemberName) {
        this.vendorMemberName = vendorMemberName;
    }

    public Long getSupplyMemberId() {
        return supplyMemberId;
    }

    public void setSupplyMemberId(Long supplyMemberId) {
        this.supplyMemberId = supplyMemberId;
    }

    public Long getSupplyRoleId() {
        return supplyRoleId;
    }

    public void setSupplyRoleId(Long supplyRoleId) {
        this.supplyRoleId = supplyRoleId;
    }

    public String getSupplyMemberName() {
        return supplyMemberName;
    }

    public void setSupplyMemberName(String supplyMemberName) {
        this.supplyMemberName = supplyMemberName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }

        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        OrderSeparateDTO that = (OrderSeparateDTO) o;
        return Objects.equals(vendorMemberId, that.vendorMemberId) &&
                Objects.equals(vendorRoleId, that.vendorRoleId) &&
                Objects.equals(supplyMemberId, that.supplyMemberId) &&
                Objects.equals(supplyRoleId, that.supplyRoleId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(vendorMemberId, vendorRoleId, supplyMemberId, supplyRoleId);
    }
}
